package com.scsj.supermarket.view.fragment.followmodel;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.LinearLayout;

import com.scsj.supermarket.R;
import com.scsj.supermarket.adapter.FollowShopFilterAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * 店铺关注 - 筛选
 */
public class FollowShopFilter extends Fragment {
    private LinearLayout ll_back;
    private DrawerLayout mDrawerLayout;
    private FrameLayout mDrawerContent;

    private RecyclerView recycler_view;
    private FollowShopFilterAdapter filterAdapter;
    private List<String> mDatas;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_follow_shop_filter, null);
        initView(view);
        initListener();
        initData();
        return view;
    }

    private void initView(View view) {
        String departmentName = getArguments().getString("departmentName");
        ll_back = view.findViewById(R.id.ll_back);
        recycler_view = view.findViewById(R.id.recycler_view);
        recycler_view.setLayoutManager(new LinearLayoutManager(getActivity()));
        recycler_view.setNestedScrollingEnabled(false);

    }

    private void initListener() {
        mDrawerLayout = (DrawerLayout) getActivity().findViewById(R.id.drawer_layout);
        mDrawerContent = (FrameLayout) getActivity().findViewById(R.id.drawer_content);
        ll_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mDrawerLayout.closeDrawer(mDrawerContent);
            }
        });
    }

    protected void initData() {
        mDatas = new ArrayList<>();
        mDatas.add("家用电器");
        mDatas.add("鞋靴");
        mDatas.add("户外运动");
        mDatas.add("个护化妆");
        mDatas.add("电脑办公");
        filterAdapter = new FollowShopFilterAdapter(mDatas);
        recycler_view.setAdapter(filterAdapter);
    }
}
